\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 s possible to structure your application so that there
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 i
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 s a separate Mach thread that does nothing or little else than service this
\b msg_receive
\b0 .
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 This should provide the response time you need.
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 For example, if you use the Music Kit, there
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 i
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 s a new feature in 2.0 that allows the Music Kit performance (and, hence, the MIDI
\b msg_receive
\b0 ) to run in a separate thread from the graphics event loop.
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 (This feature is also useful for non-MIDI performances, such as those using DSP synthesis.)
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 Alternatively, if you don't use the Music Kit, you can fork your own thread to handle the MIDI asynchronous
\pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 to the event loop. \
\
Running the Music Kit in a separate thread will make it unlikely that graphics will prevent you from receiving your MIDI in a timely fashion. However, the Music Kit scheduler (just like the Appkit event loop) is non-preemptive—there's no absolute limit to how much can be done before going back to the
\b msg_receive
\b0 . Therefore, if you write your own Performer, Instrument, or NoteFilter subclass, make it as efficient as possible, because you won't receive MIDI until you exit your code. In principle, the way to get the fastest MIDI response is to have your own separate thread loop processing the MIDI, without using the Music Kit. However, if that thread does much processing other than receiving MIDI, using the Music Kit would probably be just as efficient (and easier to program). The important thing is to get back to the
\b msg_receive
\b0 as quickly as possible, whether in the Music Kit, the Appkit, or your own thread.\
\
As an example of a multi-threaded Music Kit application, see /NextDeveloper/Examples/MusicKit/PerformerExample (not in release 1.0). As an example of Music Kit MIDI processing, see /NextDeveloper/Examples/MusicKit/MidiEcho. As a complex example of using the Music Kit, see /NextDeveloper/Examples/MusicKit/Ensemble (not in release 1.0). Finally, if you don't use the Music Kit, see the Cthreads documentation for how to run the MIDI loop in a separate thread. \